// apply的实现和call思路一样 只是需要区别有参数和没参数的情况
Function.prototype.myapply = function (thisArg) {
  let context = thisArg || window;
  context["fn"] = this;
  if (arguments[1]) {
    // 传入参数
    let argus = Array.from(arguments)[1];
    context["fn"](...argus);
  } else {
    // 没参数
    context["fn"]();
  }
  delete context["fn"];
};

function play(name, age) {
  console.log(name + age); //coderqian22
  console.log(this.name); //obj-coderqian
}

let obj = {
  name: "obj-coderqian",
};
// play.call(obj, "112");
play.myapply(obj, ["coderqian", 22]);
